package net.homelinux.chaoswg.io.renga.krypto.animations.Xor;

import net.homelinux.chaoswg.io.renga.core.animations.State;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.vectors.BitVector;

public class XorState implements State {
    int inverseIndex = -1;
    
    BitVector bv0 = new BitVector();
    BitVector bv1 = new BitVector();
    BitVector result = new BitVector();
    
    public XorState (final BitVector bv0, final BitVector bv1) {
        this.bv0 = bv0;
        this.bv1 = bv1;
        this.result = new BitVector (bv0.getSize());        
    }
    
    public XorState () {
    }

    public BitVector getBv0() {
        return bv0;
    }

    public void setBv0(final BitVector bv0) {
        this.bv0 = bv0;
    }

    public BitVector getBv1() {
        return bv1;
    }

    public void setBv1(final BitVector bv1) {
        this.bv1 = bv1;
    }

    public int getInverseIndex() {
        return inverseIndex;
    }

    public void setInverseIndex(final int inverseIndex) {
        this.inverseIndex = inverseIndex;
    }

    public BitVector getResult() {
        return result;
    }

    public void setResult(final BitVector result) {
        this.result = result;
    }
    
    public int getSize () {
        return result.getSize ();
    }

    public void setOperand(final int slot, final Object value) {
        if (value instanceof BitVector) {
            switch (slot) {
                case 0:
                    bv0 = ((BitVector)value);
                    result = new BitVector (bv0.getSize());
                    break;
                case 1:
                    bv1 = ((BitVector)value);
                    result = new BitVector (bv1.getSize());
                    break;
            }
        }
    }
}
